<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者，助力中小企业发展 
+----------------------------------------------------------------------
| Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
+----------------------------------------------------------------------
| 沃德代驾系统并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
+----------------------------------------------------------------------
| 组件-司机报单二维码弹窗 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->

<template>
	<view class="component-modal-create-order" @click.stop>
		<uni-popup ref="popupModal" type="center" @change="onChange">
			<view class="popup-box" :style="{'--theme-color': themeColor}">
				<view class="popup-header">
					<view class="title">报单类型</view>
					<image class="close" src="/static/close.png" mode="aspectFit" @click="onClose"></image>
				</view>
				<view class="popup-content">
					<view class="content-item" :class="{select: selectType == 1}" @click="selectType = 1">
						<view class="item-text">手机号报单</view>
						<view class="item-select">
							<image src="/static/tick.png" mode="aspectFit"></image>
						</view>
					</view>
					<view class="content-item" :class="{select: selectType == 2}" @click="selectType = 2">
						<view class="item-text">扫码报单</view>
						<view class="item-select">
							<image class="select-icon" src="/static/tick.png" mode="aspectFit"></image>
						</view>
					</view>
				</view>
				<view class="popup-btn" @click="onConfirm">确认选择</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import { mapState } from "vuex"
	export default {
		name: "componentModalCreateOrder",
		data() {
			return {
				// 已选报单类型
				selectType: 1,
			}
		},
		computed: {
			...mapState({
				themeColor: state => state.app.themeColor,
			})
		},
		methods: {
			// 打开模态框
			open() {
				this.$refs.popupModal.open()
			},
			// 关闭弹窗
			onClose() {
				this.$refs.popupModal.close()
			},
			// 改变事件
			onChange(e) {
				this.$emit("onChange", e.show)
			},
			// 确认
			onConfirm() {
				this.$emit("onConfirm", this.selectType)
				this.onClose()
			},
		},
	}
</script>

<style lang="scss">
	.component-modal-create-order {
		position: relative;
		z-index: 999;

		.popup-box {
			background: #FFF;
			border-radius: 32rpx;
			padding: 48rpx 52rpx 64rpx;
			width: 80vw;

			.popup-header {
				display: flex;
				align-items: center;
				padding-left: 48rpx;

				.title {
					color: #242629;
					text-align: center;
					font-size: 32rpx;
					font-weight: 600;
					line-height: 44rpx;
					flex: 1;
				}

				.close {
					width: 48rpx;
					height: 48rpx;
				}
			}

			.popup-content {
				padding-top: 32rpx;

				.content-item {
					margin-top: 32rpx;
					border-radius: 32rpx;
					overflow: hidden;
					border: 2rpx solid #F0F0F0;
					padding: 44rpx 48rpx;
					position: relative;

					.item-text {
						color: #242629;
						text-align: center;
						font-size: 32rpx;
						font-style: normal;
						font-weight: 600;
						line-height: 44rpx;

					}

					.item-select {
						display: none;
						position: absolute;
						right: 0;
						bottom: 0;
						width: 24px;
						height: 24px;
						background: var(--theme-color);
						border-top-left-radius: 12rpx;
					}

					&.select {
						border: 4rpx solid var(--theme-color);
						padding: 42rpx 46rpx;

						.item-text {
							color: var(--theme-color);
						}

						.item-select {
							display: block;
						}
					}
				}
			}

			.popup-btn {
				margin-top: 32rpx;
				color: #FFF;
				text-align: center;
				font-size: 28rpx;
				font-weight: 600;
				line-height: 40rpx;
				padding: 36rpx 48rpx;
				border-radius: 32rpx;
				background: var(--theme-color);
			}
		}
	}
</style>